package pl.edu.pk.mech.kkbus.model;

import static pl.edu.pk.mech.kkbus.staticstrings.BusStopProperty.BUS_STOP_DIRECTION;
import static pl.edu.pk.mech.kkbus.staticstrings.BusStopProperty.BUS_STOP_DIVIDER;
import static pl.edu.pk.mech.kkbus.staticstrings.BusStopProperty.BUS_STOP_ID_DEP;
import static pl.edu.pk.mech.kkbus.staticstrings.BusStopProperty.BUS_STOP_NAME;
import static pl.edu.pk.mech.kkbus.staticstrings.BusStopProperty.BUS_STOP_ORDER;
import static pl.edu.pk.mech.kkbus.staticstrings.BusStopProperty.BUS_STOP_PRICE;

import java.io.Serializable;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.google.appengine.api.datastore.Entity;
public class BusStop extends Pojo implements Serializable{

	private static final long serialVersionUID = 5767181372654625197L;

	public enum Direction {
        KRAKOW_KATOWICE,
        KATOWICE_KRAKOW
    }
    
    private String name;
    private Set<Direction> direction;
    private double price;
    private int distance;
    private int order; 
    private List<DepartureTime> departureTimes;

    public BusStop() {}

    public BusStop(Entity entity) {
        this.id = entity.getKey().getId();
        this.name = (String) entity.getProperty(BUS_STOP_NAME);
        
        this.direction = new HashSet<Direction>();
        String directionTemp = (String)entity.getProperty(BUS_STOP_DIRECTION);
        for(String temp : directionTemp.split(BUS_STOP_DIVIDER)) {
            this.direction.add(Direction.valueOf(temp));
        }
        
        this.price = Double.valueOf(entity.getProperty(BUS_STOP_PRICE).toString());
        this.distance = Integer.valueOf(entity.getProperty(BUS_STOP_PRICE).toString());
        this.order = Integer.valueOf(entity.getProperty(BUS_STOP_ORDER).toString());
        this.departureTimes = (List<DepartureTime>) entity.getProperty(BUS_STOP_ID_DEP);
    }
    
//    public BusStop(String name, Direction direction, double price, int distance, int order, List<DepartureTime> departureTimes) {
//        this.name = name;
//        this.direction = direction;
//        this.price = price;
//        this.distance = distance;
//        this.order = order;
//        this.departureTimes = departureTimes;
//    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    public Set<Direction> getDirection() {
		return direction;
	}

	public void setDirection(Set<Direction> direction) {
		this.direction = direction;
	}

	public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getDistance() {
        return distance;
    }

    public void setDistance(int distance) {
        this.distance = distance;
    }

    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    public List<DepartureTime> getDepartureTimes() {
        return departureTimes;
    }

    public void setDepartureTimes(List<DepartureTime> departureTimes) {
        this.departureTimes = departureTimes;
    }
    
}